package com.skyvin.nreceipts.common.mapper;

import java.util.ArrayList;
import java.util.List;

import org.springframework.data.domain.Page;

import com.skyvin.nreceipts.common.document.RetailerTemplate;
import com.skyvin.nreceipts.common.dto.RetailerDTO;

public class RetailerMapper {
	public static RetailerDTO map(RetailerTemplate retailer) {
		RetailerDTO retailerDTO = new RetailerDTO();
		retailerDTO.setId(retailer.getId());
		retailerDTO.setValue(retailer.getValue());
		retailerDTO.setAddress1(retailer.getAddress1());
		retailerDTO.setAddress2(retailer.getAddress2());
		retailerDTO.setCity(retailer.getCity());
		retailerDTO.setCountry(retailer.getCountry());
		retailerDTO.setEmail(retailer.getEmail());
		retailerDTO.setPhone(retailer.getPhone());
		retailerDTO.setZipcode(retailer.getZipcode());
		return retailerDTO;
	}
	
	public static List<RetailerDTO> map(Page<RetailerTemplate> retailerDocuments) {
		List<RetailerDTO> retailerDTOs = new ArrayList<RetailerDTO>();
		for (RetailerTemplate retailer : retailerDocuments) {
			retailerDTOs.add(map(retailer));
		}
		return retailerDTOs;
	}
	

}
